   cd, current = old_dir

   outputpath = old_dir + '/figures'
   if not file_test(outputpath) then file_mkdir, outputpath
   content = ''
   openr, lun, 'parameters',/get_lun
   while eof(lun) ne 1 do begin
      readf, lun, content
      if strpos(content, 'datavis_path') ne -1 then begin
         path_start = strpos(content, "'") + 1
         path_end = strpos(content, "'", /reverse_offset)
         datapath = old_dir + '/' + strmid(content, path_start, path_end - path_start)
      endif
   endwhile
   close, lun
   free_lun, lun

   filelist = file_search(datapath + '/*.mapvis', count = file_number)

   endian = 0
;   catch, bad_endian

;   if bad_endian ne 0 then begin
;      print, '|----Swap endian----|'
;      endian = 1
;      close, /all
;   endif

   output_real8_flag = 0l & nx = 0l & ny = 0l & nz = 0l
   close, /all
   openr, unit, filelist[file_number - 1], /get_lun, /f77_unformatted, swap_endian = endian
   readu, unit, output_real8_flag
   readu, unit, nx, ny, nz
   x = dblarr(nx) & y = dblarr(ny) & z = dblarr(nz)
   if output_real8_flag eq 4 then begin
      ro = fltarr(nx, ny, nz)
      vx = fltarr(nx, ny, nz)
      vy = fltarr(nx, ny, nz)
      vz = fltarr(nx, ny, nz)
      bx = fltarr(nx, ny, nz)
      by = fltarr(nx, ny, nz)
      bz = fltarr(nx, ny, nz)
      gp = fltarr(nx, ny, nz)
   endif else begin
      ro = dblarr(nx, ny, nz)
      vx = dblarr(nx, ny, nz)
      vy = dblarr(nx, ny, nz)
      vz = dblarr(nx, ny, nz)
      bx = dblarr(nx, ny, nz)
      by = dblarr(nx, ny, nz)
      bz = dblarr(nx, ny, nz)
      gp = dblarr(nx, ny, nz)
   endelse
   readu, unit, x, y, z
   readu, unit, ro
   readu, unit, vx
   readu, unit, vy
   readu, unit, vz
   readu, unit, bx
   readu, unit, by
   readu, unit, bz
   readu, unit, gp
   close, unit
   free_lun, unit

   field3dgui, bx, by, bz, x = x, y = y, z = z

;   catch, /cancel

end
